from flask import Blueprint, request
from flask_restful import Api, Resource, marshal_with

from webapp.config.api_utils import oper_log, check_auth
from webapp.dto_mapper import options_page_fields
from webapp.service.course_service import CourseService

course_option_app = Blueprint('option', __name__, url_prefix='/api/course/options')
course_option_api = Api(course_option_app)

@course_option_api.resource("", "/")
class CoptionsApi(Resource):
    @oper_log('查询课程添加和编辑时需要的选项', request)
    @check_auth('course:list', request)
    @marshal_with(options_page_fields)
    def get(self):
        return CourseService.query_all_options()

